package avicit.bdp.dcs.plugin.hbase;

import avicit.bdp.dcs.plugin.BaseDataxParam;
import avicit.bdp.dcs.plugin.DataxConstants;
import avicit.bdp.dcs.plugin.DataxJsonInterface;
import avicit.bdp.dcs.plugin.hbase.param.HBaseDataxParam;
import com.alibaba.fastjson2.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @金航数码科技有限责任公司
 * @作者：liyb
 * @邮箱：liyb@avic-digital.com
 * @创建时间： 2021-01-28 11:24
 * @类说明：
 * @修改记录：
 */
public class HBaseDataxJson implements DataxJsonInterface {

    /**
     * 获取Reader插件名称
     * @return
     */
    @Override
    public String getReaderName() {
        return DataxConstants.HBASE_READER;
    }

    /**
     * 获取Writer插件名称
     * @return
     */
    @Override
    public String getWriterName() {
        return null;
    }

    @Override
    public Map<String, Object> buildReader(BaseDataxParam param) {
        String extraParam = JSONObject.toJSONString(param.getExtraParam());
        HBaseDataxParam dataxParam = JSONObject.parseObject(extraParam, HBaseDataxParam.class);

        // 构建
        Map<String, Object> readerObj = new HashMap<>(4);
        readerObj.put(DataxConstants.NAME, getReaderName());
        Map<String, Object> parameterObj = new HashMap<>(8);
        parameterObj.put(DataxConstants.HBASE_CONFIG, dataxParam.getReaderHbaseConfig());
        parameterObj.put(DataxConstants.HBASE_MODE, dataxParam.getReaderMode());
        readerObj.put(DataxConstants.PARAMETER, parameterObj);
        return readerObj;
    }

    @Override
    public Map<String, Object> buildWriter(BaseDataxParam param) {
        return null;
    }

}
